package com.deng.maintenance.navigation.view
{
	import com.deng.maintenance.vo.NavigationVo;
	import com.deng.util.GlobalProperties;
	
	import mx.collections.ArrayCollection;
	
	public class NavigationControl
	{
		private static var modelLocator:NavigationControl;
		public function NavigationControl()
		{
		}
		public static function getInstance():NavigationControl{
		     if(modelLocator==null){
		       modelLocator=new NavigationControl();
		     }
		     return modelLocator;
		}
		
		private var list:ArrayCollection = new ArrayCollection();
		
		public function inputVo(vo:NavigationVo):void{
			list.addItem(vo);
		}  
		public function clear():void{
			list.removeAll();
		}
		public function getNext():NavigationVo{
			for(var i:int = 0;i< list.length;i++){
				var vo:NavigationVo = list.getItemAt(i) as NavigationVo;
				if(vo.stat == GlobalProperties._IS_EFFECTIVE){
					return vo;
				}
			}
			return null;
		}
		public function isNull():Boolean{
			if(list == null || list.length == 0){
				return true;
			}
			return false;
		}
//		public function closeThis(vo:NavigationVo):void{
//			for(var i:int = 0;i< list.length;i++){
//				var tvo:NavigationVo = list.getItemAt(i) as NavigationVo;
//				if(tvo.type_name == vo.type_name){
//					tvo.stat = GlobalProperties._NOT_EFFECTIVE;
//					return;
//				}
//			}
//		}
		public function closeThis():void{
			for(var i:int = 0;i< list.length;i++){
				var tvo:NavigationVo = list.getItemAt(i) as NavigationVo;
				if(tvo.stat == GlobalProperties._IS_EFFECTIVE){
					tvo.stat = GlobalProperties._NOT_EFFECTIVE;
					return;
				}
			}
		}
		public function getBack():NavigationVo{
			for(var i:int = list.length-1;i>=0;i--){
				var vo:NavigationVo = list.getItemAt(i) as NavigationVo;
				if(vo.stat == GlobalProperties._IS_EFFECTIVE){
					return vo;
				}
			}
			return null;
		}
		
	}
}